package spring.cloud.tasks.api.database.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import spring.cloud.tasks.api.database.entity.StatisticsDto;
import spring.cloud.tasks.api.database.repository.StatisticsDtoRepository;
import spring.cloud.tasks.api.database.service.StatisticsDtoService;

@Service
public class StatisticsDtoServiceImpl implements StatisticsDtoService {

    @Autowired
    private StatisticsDtoRepository statisticsDtoRepository;


    @Transactional
    @Override
    public int insert(StatisticsDto statisticsDto) {
        return statisticsDtoRepository.insert(statisticsDto);
    }

    @Transactional
    @Override
    public int update(StatisticsDto statisticsDto) {
        return statisticsDtoRepository.update(statisticsDto);
    }

    @Transactional
    @Override
    public int delete(Integer id) {
        return statisticsDtoRepository.delete(id);
    }


    @Transactional(readOnly = true)
    @Override
    public StatisticsDto findStatisticsByZooKeeperAddressListAndType(String name, String zooKeeperAddressList) {
        return statisticsDtoRepository.findStatisticsByNameAndZooKeeperAddressList(zooKeeperAddressList, name);
    }

}
